var express = require('express');
var router = express.Router();
var mysql = require('mysql');
var util = require('util');
var jl = require('../db/jl.js');

/* TEST Mysql */
router.get('/test', function (req,res,next){
  var client = jl.getConnection();
  client.connect();
  jl.getDataFromTableTest(client,function(results){
    if (results){
      res.render('mdc/test', {results: results});
      console.log(util.inspect(results));
    }else{
      res.render('error');
    }
  });
});



/* GET table page */
/* 产线叫料系统测试页面 */
router.get('/table' , function(req,res,next){
  res.render('mdc/table', {
    info: [{
      id: 1,
      line: 'line11',
      class: '白班',
      matnr: '44-8889999',
      matnr_info: 'BLU 背光源背光源',
      number: 55,
      time: '2016/3/10',
      beizhu: '紧急需求',
      user: '118663',
      zconf: 'x'
    },{
      id: 2,
      line: 'line11',
      class: '夜班',
      matnr: '44-8889999',
      matnr_info: 'BLU 背光源背光源',
      number: 55,
      time: '2016/3/10',
      beizhu: '紧急需求',
      user: '118663',
      zconf: ''
    },{
      id: 3,
      line: 'line11',
      class: '夜班',
      matnr: '44-8889999',
      matnr_info: 'BLU 背光源背光源',
      number: 55,
      time: '2016/3/10',
      beizhu: '紧急需求',
      user: '118663',
      zconf: ''
    }]
  });
});

module.exports = router;
